package at.fhooe.engine.physics;

import java.awt.Graphics2D;

public class SphereBody extends CircleBody {

	private double m_zPosition;
	private double m_zVelocity;
	private double m_zAcceleration;

	public SphereBody(String name, double radius, boolean isEntity) {
		super(name, radius, isEntity);
		m_zPosition = 0;
		m_zVelocity = 0;
		m_zAcceleration = 0;
	}

	@Override
	public void setPosition(double x, double y, double z) {
		super.setPosition(x, y, z);
		m_zPosition = z;
	}

	public double getPositionZ() {
		return m_zPosition;
	}

	public double getVelocityZ() {
		return m_zVelocity;
	}

	public double getAccelerationZ() {
		return m_zAcceleration;
	}

	@Override
	public void setVelocity(double velX, double velY, double velZ) {
		super.setVelocity(velX, velY, velZ);
		m_zVelocity = velZ;
	}

	@Override
	public void setAcceleration(double accX, double accY, double accZ) {
		super.setAcceleration(accX, accY, accZ);
		m_zAcceleration = accZ;
	}

	public boolean isColliding(SphereBody sphereBody) {
		double deltaX = getPositionX() - sphereBody.getPositionX();
		double deltaY = getPositionY() - sphereBody.getPositionY();
		double deltaZ = getPositionZ() - sphereBody.getPositionZ();
		double radius = getRadius() + sphereBody.getRadius();

		return deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ < radius * radius;
	}
}
